//我的回答！！！！！！！！！！！！！！！！！
var isover=0;
var currentIndex=1;//页码
$().ready(function(){
    aj();
});
//ba4d39d74ed0fdcb
var ajaxrunning="yes";//初始不能滚动
function aj(){
    if(isover===0){
        ajaxrunning="yes";
        $.ajax({
            type:"get",
            datatype: "json",
            url: myanswerurl+"?userId="+id+"&pageSize=15&currentIndex="+currentIndex,
            success:function(data){
                console.log(data);
                if(data.Message==="没有数据"){
                    isover=1;//没有数据了
                    $("#waiting").css("display","none");
                    $("#nonews").css("display","block");
                }else{
                    if(data.Data&&data.Data.length>0){
                        if(data.Data.length<15){
                            $("#waiting").css("display","none");
                            $("#nonews").css("display","block");
                        }

                        var num=0;
                        for(var i=0;i<data.Data.length;i++){
                            num++;
                            if(num===data.Data.length){
                                ajaxrunning="no";
                            }
                            //用户昵称
                            var unick1="";
                            //var thisRealName="";
                            if(data.Data[i].userId!=id){
                                unick1="<a href='otherpeoplepage.html?otherid="+data.Data[i].userId+"'>匿名</a>";
                            }else{
                                unick1="<a>"+data.Data[i].userNick+"</a>";
                            }
                            //if(data.Data[i].isHideName==1&&data.Data[i].userId!=id){
                            //    unick1="匿名";
                            //    thisRealName="";
                            //}else{
                            //    unick1="<a href='otherpeoplepage.html?otherid="+data.Data[i].userId+"'>"+data.Data[i].userNick+"</a>";
                            //    if(data.Data[i].realName){
                            //        unick1="<a href='otherpeoplepage.html?otherid="+data.Data[i].userId+"'>"+data.Data[i].userNick+" ("+data.Data[i].realName+")</a>";
                            //    }
                            //}

                            var count=0;
                            var tim=data.Data[i].actime.match(/([0-9\-]+)/)[0];
                            if(data.Data[i].actime){
                                tim=getDateDiff(getDateTimeStamp(data.Data[i].actime));
                            };
                            if(!tim){tim="刚刚"};
                            if(data.Data[i].browseCount){count=data.Data[i].browseCount;}
                            var money="<span class='havemy'><img src='img/money04.png'>"+parseFloat(data.Data[i].score)/100+"</span>";
                            //问题
                            var tit=codetoface(data.Data[i].title);
                            if(data.Data[i].type===2){

                                $("#questionlist").append("<div class='pagedlist_item'><div class='feed_item feed_type_question'><img class='imglogo' src='img/xuanshang.png'><div class='EventHeader'><span class='senduser'>"+unick1+"</span><span class='job'> </span>"+money+"</div><h2><a class='question_link' href='questiondetail.html?qid="+data.Data[i].id+"#fromuser="+id+"'>"+tit+"</a></h2><div class='ContentFooter QuestionFooter' style='display:inline-block'>浏览 "+count+"</div><div class='rt' style='color:#999;font-size:12px;'>"+tim+"回复</div></div></div>")
                            }
                            //经验
                            else{
                                var logoimg="<img class='imglogo' src='img/jingyan.png'>";
                                //if(data.Data[i].type!==3){
                                //    logoimg="<img class='imglogo' src='img/ziyuan2333.png'>";
                                //}
                                $("#questionlist").append("<div class='pagedlist_item'><div class='feed_item feed_type_question'>"+logoimg+"<div class='EventHeader'><span class='senduser'>"+unick1+"</span><span class='job'> </span>"+money+"</div><h2><a class='question_link' href='shareexppage.html?eid="+data.Data[i].id+"#fromuser="+id+"' id='q"+data.Data[i].id+"'>"+tit+"</a></h2><div class='ContentFooter QuestionFooter' style='display:inline-block'>浏览 "+data.Data[i].browseCount+"</div><div class='rt' style='color:#999;font-size:12px;'>"+tim+"回复</div></div></div>")
                            }
                        }
                    }
                    else{
                        $("#waiting").css("display","none");
                        $("#nonews").css("display","block");
                    }
                }

            }
        })
    }

}
$(".mweb_modal_back_button").click(function(){
    if(document.referrer){
        history.go(-1);
    }else{
        location.href="setpage.html";
    }
});
$(window).scroll(function(){
    var mainheight=$(".home_feed").height();
    //console.log("加载区域高度："+mainheight);
    var windowheight=$(window).height();
    //console.log("窗口高度："+windowheight);
    var what=$(".home_feed").offset().top;
    var chajuli=$(".home_feed").offset().top - $(window).scrollTop();
    var cz=windowheight-mainheight+50;
    //console.log("窗口与加载差值："+cz);
    //console.log("差值"+chajuli);
    if(chajuli<cz&&ajaxrunning==="no"){
        currentIndex++;
        aj();
    }
});